﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using Chinaer.Model;
using Chinaer.WCF.Contracts;
using Chinaer.Core.Helper;
using System.IO;
using Chinaer.Core.Helper.Mobile;
using System.ServiceModel.Activation;
using Chinaer.Log;
using Chinaer.Common.Extensions;
using Chinaer.Core.BaseCore.Extensions;

namespace Chinaer.WCF.Services
{
    [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall, ConcurrencyMode = ConcurrencyMode.Multiple)]
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
    public class ChinaerService : Repository, IChinaer
    {

        public DTO.ShangJiaDTO LoginShangJia(DTO.ShangJiaDTO shangjiaDTO)
        {
            //添加到登陆详情表中           
            WriteLog("LoginShangJia:", Chinaer.Core.Helper.SerializeHelper.Serialize(shangjiaDTO));

            DTO.ShangJiaDTO shangjia = new DTO.ShangJiaDTO();
            try
            {
                IBll.ILogin login = new Bll.Login();
                shangjia = login.LoginShangJia(shangjiaDTO);
            }
            catch (Exception ex)
            {
                //  Chinaer.Core.Helper.ExceptonHelper.ThrowException("LoginShangjia 出现了异常:" + Chinaer.Core.Helper.ExceptionMessageHelper.RollException(ex));
                Bll.ExceptionRepository.AddException(ex);
                shangjia.LoginStatus = Core.BaseCore.LoginStatus.Exception;
                Logger.WriteErrorLog("LoginShangJiaException", ex);

            }
            return shangjia;
        }

        public DTO.ShangJiaDTO LoginShangJiaByNameAndPassword(string loginName, string loginPassword)
        {
            WriteLog("LoginShangJiaByNameAndPassword", string.Format("loginName:{0} loginPassword:{1}", loginName, loginPassword));
            if (loginName.CheckIsNull().Success == false)
            {
                return new DTO.ShangJiaDTO()
                {
                    LoginStatus = Chinaer.Core.BaseCore.LoginStatus.UserNameIsNull
                };
            }

            if (loginPassword.CheckIsNull().Success == false)
            {
                return new DTO.ShangJiaDTO()
                {
                    LoginStatus = Chinaer.Core.BaseCore.LoginStatus.PasswordIsNull
                };
            }
            //添加到登陆详情表中                       
            DTO.ShangJiaDTO shangJiaDTO = new DTO.ShangJiaDTO()
            {
                LoginName = loginName,
                LoginPassword = loginPassword
            };
            return LoginShangJia(shangJiaDTO);
        }

        public DTO.AdministratorDTO LoginAdministrator(DTO.AdministratorDTO administratorDTO)
        {
            try
            {
                WriteLog("LoginAdministrator:" + Chinaer.Core.Helper.SerializeHelper.Serialize(administratorDTO));

                IBll.ILogin login = new Bll.Login();
                return login.LoginAdministrator(administratorDTO);
            }
            catch (Exception ex)
            {
                Bll.ExceptionRepository.AddException(ex);
                Logger.WriteErrorLog("LoginAdministratorException", ex);
                return new DTO.AdministratorDTO()
                {
                    LoginStatus = Chinaer.Core.BaseCore.LoginStatus.Exception
                };
            }
        }

        public DTO.AdministratorDTO LoginAdministratorByNameAndPassword(string loginName, string loginPassword)
        {
            WriteLog("LoginAdministratorByNameAndPassword", string.Format("loginName:{0} loginPassword:{1}", loginName, loginPassword));
            DTO.AdministratorDTO administratorDTO = new DTO.AdministratorDTO()
            {
                LoginName = loginName,
                LoginPassword = loginPassword
            };
            return LoginAdministrator(administratorDTO);
        }

        public DTO.CustomerDTO LoginCustomerByNameAndPassword(string loginName, string loginPassword)
        {
            WriteLog("LoginCustomerByNameAndPassword", string.Format("loginName:{0} loginPassword:{1}", loginName, loginPassword));
            DTO.CustomerDTO customerDTO = new DTO.CustomerDTO()
            {
                LoginName = loginName,
                LoginPassword = loginPassword
            };
            return LoginCustomer(customerDTO);
        }

        public DTO.CustomerDTO LoginCustomer(DTO.CustomerDTO customerDTO)
        {
            try
            {
                WriteLog("LoginCustomer:", Chinaer.Core.Helper.SerializeHelper.Serialize(customerDTO));
                IBll.ILogin login = new Bll.Login();
                return login.LoginCustomer(customerDTO);
            }
            catch (Exception ex)
            {
                //TODO:将异常信息保存到数据库中 定义一个自动保存的Helper
                //Chinaer.Core.Helper.ExceptonHelper.ThrowException(ex.Message);
                Bll.ExceptionRepository.AddException(ex);
                Logger.WriteErrorLog("LoginCustomerException", ex);
                return new DTO.CustomerDTO()
                {
                    LoginStatus = Chinaer.Core.BaseCore.LoginStatus.Exception
                };
            }
        }

        public DTO.EmployeeDTO LoginEmployee(DTO.EmployeeDTO employeeDTO)
        {
            try
            {
                WriteLog("LoginEmployee:", Chinaer.Core.Helper.SerializeHelper.Serialize(employeeDTO));
                IBll.ILogin login = new Bll.Login();
                return login.LoginEmployee(employeeDTO);
            }
            catch (Exception ex)
            {
                Bll.ExceptionRepository.AddException(ex);
                Logger.WriteErrorLog("LoginEmployeeException", ex);
                return new DTO.EmployeeDTO()
                {
                    LoginStatus = Chinaer.Core.BaseCore.LoginStatus.Exception
                };
            }
        }

        public Chinaer.Model.Common.JsonResult RegisterShangJia(DTO.ShangJiaDTO shangjiaDTO)
        {
            WriteLog("RegisterShangJia:", Chinaer.Core.Helper.SerializeHelper.Serialize(shangjiaDTO));
            Chinaer.Model.Common.JsonResult jsonResult = new Model.Common.JsonResult();
            try
            {
                Chinaer.Core.Helper.LogHelper.Instance.WriteLog("注册商家");
                IBll.IRegister register = new Bll.Register();
                return register.RegisterShangJia(shangjiaDTO);
            }
            catch (Exception ex)
            {
                Bll.ExceptionRepository.AddException(ex);
                Logger.WriteErrorLog("RegisterShangJiaException", ex);
                jsonResult.Success = false;
                jsonResult.ErrorMessage = Chinaer.Core.Helper.ExceptionMessageHelper.RollException(ex);
                jsonResult.LoginStatus = Chinaer.Core.BaseCore.LoginStatus.Exception;
            }
            return jsonResult;

        }

        public Chinaer.Model.Common.JsonResult RegisterAdministrator(DTO.AdministratorDTO administratorDTO)
        {
            WriteLog("RegisterAdministrator:", Chinaer.Core.Helper.SerializeHelper.Serialize(administratorDTO));
            Model.Common.JsonResult jsonResult = new Model.Common.JsonResult();
            try
            {

                WriteLog("RegisterAdministrator:" + Chinaer.Core.Helper.SerializeHelper.Serialize(administratorDTO));
                IBll.IRegister register = new Bll.Register();
                jsonResult = register.RegisterAdministrator(administratorDTO);
            }
            catch (Exception ex)
            {
                Bll.ExceptionRepository.AddException(ex);
                Logger.WriteErrorLog("RegisterAdministratorException", ex);
                jsonResult.Success = false;
                jsonResult.LoginStatus = Chinaer.Core.BaseCore.LoginStatus.Exception;
                jsonResult.ErrorMessage = Chinaer.Core.Helper.ExceptionMessageHelper.RollException(ex);
            }
            return jsonResult;
        }

        public Chinaer.Model.Common.JsonResult RegisterCustomer(DTO.CustomerDTO customerDTO)
        {
            WriteLog("RegisterCustomer:", Chinaer.Core.Helper.SerializeHelper.Serialize(customerDTO));
            Chinaer.Model.Common.JsonResult jsonResult = new Model.Common.JsonResult();
            //判断实体是否为空
            jsonResult = customerDTO.CheckIsNull();
            if (jsonResult.Success == false)
            {
                return jsonResult;
            }
            try
            {
                WriteLog("RegisterCustomer:" + Chinaer.Core.Helper.SerializeHelper.Serialize(customerDTO));

                IBll.IRegister register = new Bll.Register();
                jsonResult = register.RegisterCustomer(customerDTO);
            }
            catch (Exception ex)
            {
                Bll.ExceptionRepository.AddException(ex);
                Logger.WriteErrorLog("RegisterCustomerException", ex);
                jsonResult.Success = false;
                jsonResult.LoginStatus = Chinaer.Core.BaseCore.LoginStatus.Exception;
                jsonResult.ErrorMessage = Chinaer.Core.Helper.ExceptionMessageHelper.RollException(ex);
            }
            return jsonResult;
        }

        public Chinaer.Model.Common.JsonResult RegisterEmployee(DTO.EmployeeDTO employeeDTO)
        {
            WriteLog("RegisterEmployee:", Chinaer.Core.Helper.SerializeHelper.Serialize(employeeDTO));
            Chinaer.Model.Common.JsonResult jsonResult = new Model.Common.JsonResult();
            try
            {
                WriteLog("RegisterEmployee:" + Chinaer.Core.Helper.SerializeHelper.Serialize(employeeDTO));
                IBll.IRegister register = new Bll.Register();
                jsonResult = register.RegisterEmployee(employeeDTO);
            }
            catch (Exception ex)
            {
                Bll.ExceptionRepository.AddException(ex);
                Logger.WriteErrorLog("RegisterEmployeeException", ex);
                jsonResult.Success = false;
                jsonResult.LoginStatus = Chinaer.Core.BaseCore.LoginStatus.Exception;
                jsonResult.ErrorMessage = Chinaer.Core.Helper.ExceptionMessageHelper.RollException(ex);
            }
            return jsonResult;
        }

        public DTO.DianPuDTO GetDianPuInfo(string dianPuID, string apiToken)
        {
            WriteLog("GetDianPuInfo:", dianPuID);
            try
            {
                if (apiToken.CheckIsNull().Success == false)
                {
                    return new DTO.DianPuDTO()
                    {
                        LoginStatus = Chinaer.Core.BaseCore.LoginStatus.NonLogin
                    };
                }
                IBll.IDianPu dianPu = new Bll.DianPu();
                return dianPu.GetDianPu(dianPuID);
            }
            catch (Exception ex)
            {
                Bll.ExceptionRepository.AddException(ex);
                Logger.WriteErrorLog("GetDianPuInfoException", ex);
                return new DTO.DianPuDTO()
                {
                    LoginStatus = Chinaer.Core.BaseCore.LoginStatus.Exception
                };
            }
        }

        public Chinaer.Model.Common.JsonResult UpdateDianPuInfo(DTO.DianPuDTO dianPuDTO)
        {
            WriteLog("UpdateDianPuInfo:", Chinaer.Core.Helper.SerializeHelper.Serialize(dianPuDTO));
            Model.Common.JsonResult jsonResult = new Model.Common.JsonResult();
            try
            {
                IBll.IDianPu dianPu = new Bll.DianPu();
                jsonResult = dianPu.Update(dianPuDTO);
            }
            catch (Exception ex)
            {
                Bll.ExceptionRepository.AddException(ex);
                Logger.WriteErrorLog("UpdateDianPuInfoException", ex);
                jsonResult.Success = false;
                jsonResult.LoginStatus = Chinaer.Core.BaseCore.LoginStatus.Exception;
                jsonResult.ErrorMessage = Chinaer.Core.Helper.ExceptionMessageHelper.RollException(ex);
            }
            return jsonResult;
        }

        public Chinaer.Model.Common.JsonResult DeleteDianPuByID(string dianPuID, string apiToken)
        {
            WriteLog("DeleteDianPuByID:", string.Format("dianPuID:{0}", dianPuID));
            Model.Common.JsonResult jsonResult = new Model.Common.JsonResult();
            try
            {
                IBll.IDianPu dianPu = new Bll.DianPu();
                jsonResult = dianPu.Delete(dianPuID);
            }
            catch (Exception ex)
            {
                Bll.ExceptionRepository.AddException(ex);
                Logger.WriteErrorLog("DeleteDianPuByIDException", ex);
                jsonResult.Success = false;
                jsonResult.LoginStatus = Chinaer.Core.BaseCore.LoginStatus.Exception;
                jsonResult.ErrorMessage = Chinaer.Core.Helper.ExceptionMessageHelper.RollException(ex);
            }
            return jsonResult;
        }

        public Chinaer.Model.Common.JsonResult DeleteDianPu(DTO.DianPuDTO dianPuDTO)
        {
            WriteLog("DeleteDianPu:", Chinaer.Core.Helper.SerializeHelper.Serialize(dianPuDTO));
            Model.Common.JsonResult jsonResult = new Model.Common.JsonResult();
            try
            {
                IBll.IDianPu dianPu = new Bll.DianPu();
                jsonResult = dianPu.Delete(dianPuDTO);
            }
            catch (Exception ex)
            {
                Bll.ExceptionRepository.AddException(ex);
                Logger.WriteErrorLog("DeleteDianPuException", ex);
                jsonResult.Success = false;
                jsonResult.LoginStatus = Chinaer.Core.BaseCore.LoginStatus.Exception;
                jsonResult.ErrorMessage = Chinaer.Core.Helper.ExceptionMessageHelper.RollException(ex);
            }
            return jsonResult;
        }

        public Chinaer.Model.Common.JsonResult AddDianPu(DTO.DianPuDTO dianPuDTO)
        {
            WriteLog("AddDianPu:", Chinaer.Core.Helper.SerializeHelper.Serialize(dianPuDTO));
            Model.Common.JsonResult jsonResult = new Model.Common.JsonResult();
            try
            {
                IBll.IDianPu dianPu = new Bll.DianPu();
                jsonResult = dianPu.Add(dianPuDTO);
            }
            catch (Exception ex)
            {
                Bll.ExceptionRepository.AddException(ex);
                Logger.WriteErrorLog("AddDianPuException", ex);
                jsonResult.Success = false;
                jsonResult.ErrorMessage = Chinaer.Core.Helper.ExceptionMessageHelper.RollException(ex);
                jsonResult.LoginStatus = Chinaer.Core.BaseCore.LoginStatus.Exception;
            }
            return jsonResult;
        }

        public List<DTO.MenuCategoryDTO> GetAllMenuCategory()
        {
            WriteLog("GetAllMenuCategory", "参数为空");
            try
            {
                IBll.IMenuCategory menuCategory = new Bll.MenuCategory();
                List<DTO.MenuCategoryDTO> listMenuCategoryDTO = menuCategory.GetAllMenuCategory();
                return listMenuCategoryDTO;
            }
            catch (Exception ex)
            {
                Bll.ExceptionRepository.AddException(ex);
                Log.Logger.WriteErrorLog("GetAllMenuCategoryException", ex);
            }
            return null;
        }

        public Chinaer.Model.Common.JsonResult AddMenuCategory(DTO.MenuCategoryDTO menuCategoryDTO)
        {
            WriteLog("AddMenuCategory", Chinaer.Core.Helper.SerializeHelper.Serialize(menuCategoryDTO));
            Model.Common.JsonResult jsonResult = new Model.Common.JsonResult();
            try
            {
                IBll.IMenuCategory menuCategory = new Bll.MenuCategory();
                jsonResult = menuCategory.Add(menuCategoryDTO);
            }
            catch (Exception ex)
            {
                Bll.ExceptionRepository.AddException(ex);
                Logger.WriteErrorLog("AddMenuCategoryException", ex);
                jsonResult.Success = false;
                jsonResult.LoginStatus = Chinaer.Core.BaseCore.LoginStatus.Exception;
                jsonResult.ErrorMessage = Chinaer.Core.Helper.ExceptionMessageHelper.RollException(ex);
            }
            return jsonResult;
        }

        public Chinaer.Model.Common.JsonResult DeleteMenuCategoryByID(string menuCategoryID, string apiToken)
        {
            WriteLog("DeleteMenuCategoryByID", string.Format("menuCategoryID:{0} apiToken:{1}", menuCategoryID, apiToken));
            Model.Common.JsonResult jsonResult = new Model.Common.JsonResult();
            try
            {
                IBll.IMenuCategory menuCategory = new Bll.MenuCategory();
                jsonResult = menuCategory.Delete(menuCategoryID);
            }
            catch (Exception ex)
            {
                Bll.ExceptionRepository.AddException(ex);
                Logger.WriteErrorLog("DeleteMenuCategoryByIDException", ex);
                jsonResult.Success = false;
                jsonResult.LoginStatus = Chinaer.Core.BaseCore.LoginStatus.Exception;
                jsonResult.ErrorMessage = Chinaer.Core.Helper.ExceptionMessageHelper.RollException(ex);
            }
            return jsonResult;
        }

        public Chinaer.Model.Common.JsonResult DeleteMenuCategory(DTO.MenuCategoryDTO menuCategoryDTO)
        {
            WriteLog("DeleteMenuCategory", Chinaer.Core.Helper.SerializeHelper.Serialize(menuCategoryDTO));
            Model.Common.JsonResult jsonResult = new Model.Common.JsonResult();
            try
            {
                IBll.IMenuCategory menuCategory = new Bll.MenuCategory();
                jsonResult = menuCategory.Delete(menuCategoryDTO);
            }
            catch (Exception ex)
            {
                Bll.ExceptionRepository.AddException(ex);
                Logger.WriteErrorLog("DeleteMenuCategoryException", ex);
                jsonResult.Success = false;
                jsonResult.LoginStatus = Chinaer.Core.BaseCore.LoginStatus.Exception;
                jsonResult.ErrorMessage = Chinaer.Core.Helper.ExceptionMessageHelper.RollException(ex);
            }
            return jsonResult;
        }

        public Chinaer.Model.Common.JsonResult UpdateMenuCategory(DTO.MenuCategoryDTO menuCategoryDTO)
        {
            WriteLog("UpdateMenuCategory:", Chinaer.Core.Helper.SerializeHelper.Serialize(menuCategoryDTO));
            Model.Common.JsonResult jsonResult = new Model.Common.JsonResult();
            try
            {
                IBll.IMenuCategory menuCategory = new Bll.MenuCategory();
                jsonResult = menuCategory.Update(menuCategoryDTO);
            }
            catch (Exception ex)
            {
                Bll.ExceptionRepository.AddException(ex);
                Logger.WriteErrorLog("UpdateMenuCategoryException", ex);
                jsonResult.Success = false;
                jsonResult.LoginStatus = Chinaer.Core.BaseCore.LoginStatus.Exception;
                jsonResult.ErrorMessage = Chinaer.Core.Helper.ExceptionMessageHelper.RollException(ex);
            }
            return jsonResult;
        }

        public List<DTO.MenuDetailDTO> GetMenuDeatilByMenuCategoryID(string menuCategoryID, string apiToken)
        {
            WriteLog("GetMenuDeatilByMenuCategoryID:", string.Format("menucategoryID:{0} apiToken:{1}", menuCategoryID, apiToken));
            try
            {
                IBll.IMenuDetail menuDetail = new Bll.MenuDeatil();
                return menuDetail.GetMenuDetailByMenuCategory(menuCategoryID);
            }
            catch (Exception ex)
            {
                Bll.ExceptionRepository.AddException(ex);
                Logger.WriteErrorLog("GetMenuDeatilByMenuCategoryIDException", ex);
                return null;
            }
        }

        public DTO.MenuDetailDTO GetMenuDeatilByID(string menuDeatilID, string apiToken)
        {
            WriteLog("GetMenuDeatilByID:", string.Format("menucategoryID:{0} apiToken:{1}", menuDeatilID, apiToken));
            Model.Common.JsonResult jsonResult = new Model.Common.JsonResult();
            try
            {
                IBll.IMenuDetail menuDetail = new Bll.MenuDeatil();
                return menuDetail.GetMenuDetail(menuDeatilID);
            }
            catch (Exception ex)
            {
                Bll.ExceptionRepository.AddException(ex);
                Logger.WriteErrorLog("GetMenuDeatilByIDException", ex);
                return null;
            }
        }

        public Chinaer.Model.Common.JsonResult AddMenuDeatil(DTO.MenuDetailDTO menuDeatilDTO)
        {
            WriteLog("AddMenuDeatil", Chinaer.Core.Helper.SerializeHelper.Serialize(menuDeatilDTO));
            Model.Common.JsonResult jsonResult = new Model.Common.JsonResult();
            try
            {
                IBll.IMenuDetail menuDetail = new Bll.MenuDeatil();
                jsonResult = menuDetail.Add(menuDeatilDTO);
            }
            catch (Exception ex)
            {
                Bll.ExceptionRepository.AddException(ex);
                Logger.WriteErrorLog("AddMenuDeatilException", ex);
                jsonResult.Success = false;
                jsonResult.ErrorMessage = Chinaer.Core.Helper.ExceptionMessageHelper.RollException(ex);
                jsonResult.LoginStatus = Chinaer.Core.BaseCore.LoginStatus.Exception;
            }
            return jsonResult;
        }

        public Chinaer.Model.Common.JsonResult DeleteMenuDetailByID(string menuDeatilID, string apiToken)
        {
            WriteLog("DeleteMenuDetailByID:", string.Format("menuDetailID:{0} apiToken:{1}", menuDeatilID, apiToken));
            Model.Common.JsonResult jsonResult = new Model.Common.JsonResult();
            try
            {
                IBll.IMenuDetail menuDetail = new Bll.MenuDeatil();
                jsonResult = menuDetail.Delete(menuDeatilID);
            }
            catch (Exception ex)
            {
                Bll.ExceptionRepository.AddException(ex);
                Logger.WriteErrorLog("DeleteMenuDetailByIDException", ex);
                jsonResult.Success = false;
                jsonResult.ErrorMessage = Chinaer.Core.Helper.ExceptionMessageHelper.RollException(ex);
                jsonResult.LoginStatus = Chinaer.Core.BaseCore.LoginStatus.Exception;
            }
            return jsonResult;
        }

        public Chinaer.Model.Common.JsonResult DeleteMenuDeatil(DTO.MenuDetailDTO menuDetailDTO)
        {
            WriteLog("DeleteMenuDeatil", Chinaer.Core.Helper.SerializeHelper.Serialize(menuDetailDTO));
            Model.Common.JsonResult jsonResult = new Model.Common.JsonResult();
            try
            {
                IBll.IMenuDetail menuDetail = new Bll.MenuDeatil();
                jsonResult = menuDetail.Delete(menuDetailDTO);
            }
            catch (Exception ex)
            {
                Bll.ExceptionRepository.AddException(ex);
                Logger.WriteErrorLog("DeleteMenuDeatilException", ex);
                jsonResult.Success = false;
                jsonResult.ErrorMessage = Chinaer.Core.Helper.ExceptionMessageHelper.RollException(ex);
                jsonResult.LoginStatus = Chinaer.Core.BaseCore.LoginStatus.Exception;
            }
            return jsonResult;
        }

        public Chinaer.Model.Common.JsonResult UpdateMenuDetail(DTO.MenuDetailDTO menuDetailDTO)
        {
            WriteLog("UpdateMenuDetail", Chinaer.Core.Helper.SerializeHelper.Serialize(menuDetailDTO));
            Model.Common.JsonResult jsonResult = new Model.Common.JsonResult();
            try
            {
                IBll.IMenuDetail menuDetail = new Bll.MenuDeatil();
                jsonResult = menuDetail.Update(menuDetailDTO);
            }
            catch (Exception ex)
            {
                Bll.ExceptionRepository.AddException(ex);
                Logger.WriteErrorLog("UpdateMenuDetailException", ex);
                jsonResult.Success = false;
                jsonResult.ErrorMessage = Chinaer.Core.Helper.ExceptionMessageHelper.RollException(ex);
                jsonResult.LoginStatus = Chinaer.Core.BaseCore.LoginStatus.Exception;
            }
            return jsonResult;
        }

        public List<DTO.DingDanDTO> GetDingDanByTime(string beginTime, string endTime, string dianPuID, string apiToken)
        {
            WriteLog("GetDingDanByTime:", string.Format("beginTime:{0} endTime:{1} dianPuID:{2} apiToken:{3}", beginTime, endTime, dianPuID, apiToken));
            Model.Common.JsonResult jsonResult = new Model.Common.JsonResult();
            try
            {
                IBll.IDingDan dingDan = new Bll.DingDan();
                List<DTO.DingDanDTO> listDingDanDTO = dingDan.GetDingDanByTime(Convert.ToDateTime(beginTime), Convert.ToDateTime(endTime), dianPuID, apiToken);
                return listDingDanDTO;
            }
            catch (Exception ex)
            {
                Bll.ExceptionRepository.AddException(ex);
                Logger.WriteErrorLog("GetDingDanByTimeException", ex);
                return null;
            }
        }

        public Chinaer.Model.Common.JsonResult AddDingDan(DTO.DingDanDTO dingDanDTO)
        {
            WriteLog("AddDingDan", Chinaer.Core.Helper.SerializeHelper.Serialize(dingDanDTO));

            Model.Common.JsonResult jsonResult = new Model.Common.JsonResult();
            try
            {
                IBll.IDingDan dingDan = new Bll.DingDan();
                jsonResult = dingDan.Add(dingDanDTO);
            }
            catch (Exception ex)
            {
                Bll.ExceptionRepository.AddException(ex);
                Logger.WriteErrorLog("AddDingDanException", ex);
                jsonResult.ErrorMessage = Chinaer.Core.Helper.ExceptionMessageHelper.RollException(ex);
                jsonResult.Success = false;
                jsonResult.LoginStatus = Chinaer.Core.BaseCore.LoginStatus.Exception;
            }
            return jsonResult;
        }

        public Chinaer.Model.Common.JsonResult DeleteDingDanByID(string dingDanID)
        {
            WriteLog("DeleteDingDanByID", string.Format("DingDanID:{0}", dingDanID));
            Model.Common.JsonResult jsonResult = new Model.Common.JsonResult();
            try
            {
                IBll.IDingDan dingDan = new Bll.DingDan();
                jsonResult = dingDan.Delete(dingDanID);
            }
            catch (Exception ex)
            {
                Bll.ExceptionRepository.AddException(ex);
                Logger.WriteErrorLog("DeleteDingDanByIDException", ex);
                jsonResult.ErrorMessage = Chinaer.Core.Helper.ExceptionMessageHelper.RollException(ex);
                jsonResult.Success = false;
                jsonResult.LoginStatus = Chinaer.Core.BaseCore.LoginStatus.Exception;
            }
            return jsonResult;
        }

        public Chinaer.Model.Common.JsonResult DeleteDingDan(DTO.DingDanDTO dingDanDTO)
        {
            WriteLog("DeleteDingDan", Chinaer.Core.Helper.SerializeHelper.Serialize(dingDanDTO));
            Model.Common.JsonResult jsonResult = new Model.Common.JsonResult();
            try
            {
                IBll.IDingDan dingDan = new Bll.DingDan();
                jsonResult = dingDan.Delete(dingDanDTO);
            }
            catch (Exception ex)
            {
                Bll.ExceptionRepository.AddException(ex);
                Logger.WriteErrorLog("DeleteDingDanException", ex);
                jsonResult.ErrorMessage = Chinaer.Core.Helper.ExceptionMessageHelper.RollException(ex);
                jsonResult.Success = false;
                jsonResult.LoginStatus = Chinaer.Core.BaseCore.LoginStatus.Exception;
            }
            return jsonResult;
        }

        public Chinaer.Model.Common.JsonResult UpdateDingDan(DTO.DingDanDTO dingDanDTO)
        {
            WriteLog("UpdateDingDan", Chinaer.Core.Helper.SerializeHelper.Serialize(dingDanDTO));
            Model.Common.JsonResult jsonResult = new Model.Common.JsonResult();
            try
            {
                IBll.IDingDan dingDan = new Bll.DingDan();
                jsonResult = dingDan.Update(dingDanDTO);
            }
            catch (Exception ex)
            {
                Bll.ExceptionRepository.AddException(ex);
                Logger.WriteErrorLog("UpdateDingDanException", ex);
                jsonResult.ErrorMessage = Chinaer.Core.Helper.ExceptionMessageHelper.RollException(ex);
                jsonResult.Success = false;
                jsonResult.LoginStatus = Chinaer.Core.BaseCore.LoginStatus.Exception;
            }
            return jsonResult;
        }

        public DTO.DianPuDTO GetDianPuByShangJiaID(string shangJiaID, string apiToken)
        {
            WriteLog("GetDianPuByShangJiaID", string.Format("shangJiaID:{0} apiToken:{1}", shangJiaID, apiToken));
            DTO.DianPuDTO dianPuDTO = new DTO.DianPuDTO();
            try
            {
                IBll.IDianPu dianPu = new Bll.DianPu();
                dianPuDTO = dianPu.GetDianPuByShangJiaID(shangJiaID);
                return dianPuDTO;
            }
            catch (Exception ex)
            {
                Bll.ExceptionRepository.AddException(ex);
                Logger.WriteErrorLog("GetDianPuByShangJiaIDException", ex);
                dianPuDTO.LoginStatus = Chinaer.Core.BaseCore.LoginStatus.Exception;
            }
            return dianPuDTO;
        }

        public List<DTO.MenuDetailDTO> GetMenuDetailByDianPuID(string dianPuID, string apiToken)
        {
            WriteLog("GetMenuDetailByDianPuID", string.Format("dianPuID:{0} apiToken:{1}", dianPuID, apiToken));
            try
            {
                IBll.IMenuDetail menuDetail = new Bll.MenuDeatil();
                return menuDetail.GetMenuDetailByDianPuID(dianPuID);
            }
            catch (Exception ex)
            {
                Bll.ExceptionRepository.AddException(ex);
                Logger.WriteErrorLog(ex.Message, ex);
                Chinaer.Log.Logger.WriteErrorLog("GetMenuDetailByDianPuIDException", ex);
                return null;
            }
        }

        public List<DTO.CityDTO> GetCityByProvinceID(string provinceID, string apiToken)
        {
            WriteLog("GetCityByProvinceID", string.Format("ProvinceID:{0} apiToken:{1}", provinceID, apiToken));
            try
            {
                IBll.ICity city = new Bll.City();
                return city.GetCityByProvinceID(provinceID);
            }
            catch (Exception ex)
            {
                Bll.ExceptionRepository.AddException(ex);
                Logger.WriteErrorLog("GetCityByProvinceIDException", ex);
                return null;
            }
        }

        public Chinaer.Model.Common.JsonResult AddCity(DTO.CityDTO cityDTO)
        {
            WriteLog("AddCity", Chinaer.Core.Helper.SerializeHelper.Serialize(cityDTO));
            Model.Common.JsonResult jsonResult = new Model.Common.JsonResult();
            try
            {
                IBll.ICity city = new Bll.City();
                jsonResult = city.Add(cityDTO);
            }
            catch (Exception ex)
            {
                Bll.ExceptionRepository.AddException(ex);
                Chinaer.Log.Logger.WriteErrorLog("AddCityException", ex);
                jsonResult.Success = false;
                jsonResult.ErrorMessage = Chinaer.Core.Helper.ExceptionMessageHelper.RollException(ex);
                jsonResult.LoginStatus = Chinaer.Core.BaseCore.LoginStatus.Exception;
            }
            return jsonResult;
        }

        public Chinaer.Model.Common.JsonResult DeleteCity(DTO.CityDTO cityDTO)
        {
            WriteLog("DeleteCity", Chinaer.Core.Helper.SerializeHelper.Serialize(cityDTO));
            Model.Common.JsonResult jsonResult = new Model.Common.JsonResult();
            try
            {
                IBll.ICity city = new Bll.City();
                jsonResult = city.Delete(cityDTO);
            }
            catch (Exception ex)
            {
                Bll.ExceptionRepository.AddException(ex);
                Chinaer.Log.Logger.WriteErrorLog("DeleteCityException", ex);
                jsonResult.Success = false;
                jsonResult.ErrorMessage = Chinaer.Core.Helper.ExceptionMessageHelper.RollException(ex);
                jsonResult.LoginStatus = Chinaer.Core.BaseCore.LoginStatus.Exception;
            }
            return jsonResult;
        }

        public Chinaer.Model.Common.JsonResult DeleteCityByID(string cityID, string apiToken)
        {
            WriteLog("DeleteCityByID", string.Format("cityID:{0} apiToken:{1}", cityID, apiToken));
            Model.Common.JsonResult jsonResult = new Model.Common.JsonResult();
            try
            {
                IBll.ICity city = new Bll.City();
                jsonResult = city.Delete(cityID);
            }
            catch (Exception ex)
            {
                Bll.ExceptionRepository.AddException(ex);
                Chinaer.Log.Logger.WriteErrorLog("DeleteCityByIDException", ex);
                jsonResult.Success = false;
                jsonResult.ErrorMessage = Chinaer.Core.Helper.ExceptionMessageHelper.RollException(ex);
                jsonResult.LoginStatus = Chinaer.Core.BaseCore.LoginStatus.Exception;
            }
            return jsonResult;
        }

        public Chinaer.Model.Common.JsonResult UpdateCity(DTO.CityDTO cityDTO)
        {
            WriteLog("UpdateCity", Chinaer.Core.Helper.SerializeHelper.Serialize(cityDTO));
            Model.Common.JsonResult jsonResult = new Model.Common.JsonResult();
            try
            {
                IBll.ICity city = new Bll.City();
                jsonResult = city.Update(cityDTO);
            }
            catch (Exception ex)
            {
                Bll.ExceptionRepository.AddException(ex);
                Chinaer.Log.Logger.WriteErrorLog("UpdateCityException", ex);
                jsonResult.Success = false;
                jsonResult.ErrorMessage = Chinaer.Core.Helper.ExceptionMessageHelper.RollException(ex);
                jsonResult.LoginStatus = Chinaer.Core.BaseCore.LoginStatus.Exception;
            }
            return jsonResult;
        }

        public Chinaer.Model.Common.JsonResult UpdateAddress(DTO.AddressDTO addressDTO)
        {
            WriteLog("UpdateAddress", Chinaer.Core.Helper.SerializeHelper.Serialize(addressDTO));
            Model.Common.JsonResult jsonResult = new Model.Common.JsonResult();
            try
            {
                IBll.IAddress address = new Bll.Address();
                jsonResult = address.Update(addressDTO);
            }
            catch (Exception ex)
            {
                Bll.ExceptionRepository.AddException(ex);
                Logger.WriteErrorLog("UpdateAddressException", ex);
                jsonResult.Success = false;
                jsonResult.ErrorMessage = Chinaer.Core.Helper.ExceptionMessageHelper.RollException(ex);
                jsonResult.LoginStatus = Chinaer.Core.BaseCore.LoginStatus.Exception;
            }
            return jsonResult;
        }

        public Chinaer.Model.Common.JsonResult DeleteAddress(DTO.AddressDTO addressDTO)
        {
            WriteLog("DeleteAddress", Chinaer.Core.Helper.SerializeHelper.Serialize(addressDTO));
            Model.Common.JsonResult jsonResult = new Model.Common.JsonResult();
            try
            {
                IBll.IAddress address = new Bll.Address();
                jsonResult = address.Delete(addressDTO);
            }
            catch (Exception ex)
            {
                Bll.ExceptionRepository.AddException(ex);
                Logger.WriteErrorLog("DeleteAddressException", ex);
                jsonResult.Success = false;
                jsonResult.ErrorMessage = Chinaer.Core.Helper.ExceptionMessageHelper.RollException(ex);
                jsonResult.LoginStatus = Chinaer.Core.BaseCore.LoginStatus.Exception;
            }
            return jsonResult;
        }

        public Chinaer.Model.Common.JsonResult AddAddress(DTO.AddressDTO addressDTO)
        {
            WriteLog("AddAddress", Chinaer.Core.Helper.SerializeHelper.Serialize(addressDTO));
            Model.Common.JsonResult jsonResult = new Model.Common.JsonResult();
            try
            {
                IBll.IAddress address = new Bll.Address();

                jsonResult = address.Add(addressDTO);
            }
            catch (System.Data.Entity.Validation.DbEntityValidationException ex)
            {
                Bll.ExceptionRepository.AddException(ex);
                Logger.WriteErrorLog("AddAddressException", ex);
                jsonResult.Success = false;
                jsonResult.LoginStatus = Chinaer.Core.BaseCore.LoginStatus.Exception;
                foreach (var item in ex.EntityValidationErrors)
                {
                    foreach (var item2 in item.ValidationErrors)
                    {
                        jsonResult.ErrorMessage += item2.ErrorMessage;
                    }
                }
            }
            catch (Exception ex)
            {
                Bll.ExceptionRepository.AddException(ex);
                Logger.WriteErrorLog("AddAddress", ex);
                jsonResult.Success = false;
                jsonResult.ErrorMessage = Chinaer.Core.Helper.ExceptionMessageHelper.RollException(ex);
                jsonResult.LoginStatus = Chinaer.Core.BaseCore.LoginStatus.Exception;
            }
            return jsonResult;
        }

        public Chinaer.Model.Common.JsonResult DeleteAddressByAddressID(string addressID, string apiToken)
        {
            WriteLog("DeleteAddressByAddressID", string.Format("addressID:{0} apiToken:{1}", addressID, apiToken));
            Model.Common.JsonResult jsonResult = new Model.Common.JsonResult();
            try
            {
                IBll.IAddress address = new Bll.Address();
                jsonResult = address.Delete(addressID);
            }
            catch (Exception ex)
            {
                Bll.ExceptionRepository.AddException(ex);
                Logger.WriteErrorLog("DeleteAddressByAddressIDException", ex);
                jsonResult.Success = false;
                jsonResult.ErrorMessage = Chinaer.Core.Helper.ExceptionMessageHelper.RollException(ex);
                jsonResult.LoginStatus = Chinaer.Core.BaseCore.LoginStatus.Exception;
            }
            return jsonResult;
        }

        public List<DTO.AddressDTO> GetAddressByCustomerID(string customerID, string apiToken)
        {
            WriteLog("GetAddressByCustomerID", string.Format("customerID:{0} apiToken:{1}", customerID, apiToken));
            try
            {
                IBll.IAddress address = new Bll.Address();
                return address.GetAddressByCustomerID(customerID);
            }
            catch (Exception ex)
            {
                Bll.ExceptionRepository.AddException(ex);
                Logger.WriteErrorLog("GetAddressByCustomerIDException", ex);
            }
            return null;
        }

        public DTO.AddressDTO GetAddressByAddressID(string addressID, string apiToken)
        {
            WriteLog("GetAddressByAddressID", string.Format("addressID:{0} apiToken:{1}", addressID, apiToken));
            DTO.AddressDTO addressDTO = new DTO.AddressDTO();
            try
            {
                IBll.IAddress address = new Bll.Address();
                addressDTO = address.GetByID(addressID);
            }
            catch (Exception ex)
            {
                Bll.ExceptionRepository.AddException(ex);
                Logger.WriteErrorLog("GetAddressByAddressIDException", ex);
                addressDTO.LoginStatus = Chinaer.Core.BaseCore.LoginStatus.Exception;
            }
            return addressDTO;
        }

        public Chinaer.Model.Common.JsonResult AddMenuSubCategory(DTO.MenuSubCategoryDTO menuSubCategoryDTO)
        {
            WriteLog("AddMenuSubCategory", Chinaer.Core.Helper.SerializeHelper.Serialize(menuSubCategoryDTO));
            Model.Common.JsonResult jsonResult = new Model.Common.JsonResult();
            try
            {
                IBll.IMenuSubCategory menuSubCategory = new Bll.MenuSubCategory();
                jsonResult = menuSubCategory.Add(menuSubCategoryDTO);
            }
            catch (Exception ex)
            {
                Bll.ExceptionRepository.AddException(ex);
                Logger.WriteErrorLog("AddMenuSubCategoryException", ex);
                jsonResult.Success = false;
                jsonResult.ErrorMessage = Chinaer.Core.Helper.ExceptionMessageHelper.RollException(ex);
                jsonResult.LoginStatus = Chinaer.Core.BaseCore.LoginStatus.Exception;
            }
            return jsonResult;
        }

        public Chinaer.Model.Common.JsonResult DeleteMenuSubCategory(DTO.MenuSubCategoryDTO menuSubCategoryDTO)
        {
            WriteLog("DeleteMenuSubCategory", Chinaer.Core.Helper.SerializeHelper.Serialize(menuSubCategoryDTO));
            Model.Common.JsonResult jsonResult = new Model.Common.JsonResult();
            try
            {
                IBll.IMenuSubCategory menuSubCategory = new Bll.MenuSubCategory();
                jsonResult = menuSubCategory.Delete(menuSubCategoryDTO);
            }
            catch (Exception ex)
            {
                Bll.ExceptionRepository.AddException(ex);
                Logger.WriteErrorLog("DeleteMenuSubCategoryException", ex);
                jsonResult.Success = false;
                jsonResult.ErrorMessage = Chinaer.Core.Helper.ExceptionMessageHelper.RollException(ex);
                jsonResult.LoginStatus = Chinaer.Core.BaseCore.LoginStatus.Exception;
            }
            return jsonResult;
        }

        public Chinaer.Model.Common.JsonResult UpdateMenuSubCategory(DTO.MenuSubCategoryDTO menuSubCategoryDTO)
        {
            WriteLog("UpdateMenuSubCategory", Chinaer.Core.Helper.SerializeHelper.Serialize(menuSubCategoryDTO));
            Model.Common.JsonResult jsonResult = new Model.Common.JsonResult();
            try
            {
                IBll.IMenuSubCategory menuSubCategory = new Bll.MenuSubCategory();
                jsonResult = menuSubCategory.Update(menuSubCategoryDTO);
            }
            catch (Exception ex)
            {
                Bll.ExceptionRepository.AddException(ex);
                Logger.WriteErrorLog("UpdateMenuSubCategoryException", ex);
                jsonResult.Success = false;
                jsonResult.ErrorMessage = Chinaer.Core.Helper.ExceptionMessageHelper.RollException(ex);
                jsonResult.LoginStatus = Chinaer.Core.BaseCore.LoginStatus.Exception;
            }
            return jsonResult;
        }

        public Chinaer.Model.Common.JsonResult DeleteMenuSubCategoryByID(string menuSubCategoryID, string apiToken)
        {
            WriteLog("DeleteMenuSubCategoryByID", string.Format("menuSubCategoryID:{0} apiToken:{1}", menuSubCategoryID, apiToken));
            Model.Common.JsonResult jsonResult = new Model.Common.JsonResult();
            try
            {
                IBll.IMenuSubCategory menuSubCategory = new Bll.MenuSubCategory();
                jsonResult = menuSubCategory.Delete(menuSubCategoryID);
            }
            catch (Exception ex)
            {
                Bll.ExceptionRepository.AddException(ex);
                Logger.WriteErrorLog("DeleteMenuSubCategoryByIDException", ex);
                jsonResult.Success = false;
                jsonResult.ErrorMessage = Chinaer.Core.Helper.ExceptionMessageHelper.RollException(ex);
                jsonResult.LoginStatus = Chinaer.Core.BaseCore.LoginStatus.Exception;
            }
            return jsonResult;
        }

        public List<DTO.MenuSubCategoryDTO> GetMenuSubCategoryByMenuCategoryIDAndDianPuID(string menuCategoryID, string dianPuID, string apiToken)
        {
            WriteLog("GetMenuSubCategoryByMenuCategoryIDAndDianPuID", string.Format("menuCategoryID:{0} apiToken:{1}", menuCategoryID, apiToken));
            try
            {
                IBll.IMenuSubCategory menuSubCategory = new Bll.MenuSubCategory();
                return menuSubCategory.GetMenuSubCategoryByMenuCategoryIDAndDianPuID(menuCategoryID, dianPuID);
            }
            catch (Exception ex)
            {
                Bll.ExceptionRepository.AddException(ex);
                Logger.WriteErrorLog("GetMenuSubCategoryByMenuCategoryIDAndDianPuIDException", ex);
                return null;
            }
        }

        public Chinaer.Model.Common.JsonResult AddShangJiaIsReadZhongXinGongGao(DTO.ShangJiaIsReadZhongXinGongGaoDTO shangJiaIsReadZhongXinGongGao)
        {
            WriteLog("AddShangJiaIsReadZhongXinGongGao", Chinaer.Core.Helper.SerializeHelper.Serialize(shangJiaIsReadZhongXinGongGao));
            Model.Common.JsonResult jsonResult = new Model.Common.JsonResult();
            try
            {
                IBll.IShangJiaIsReadZhongXinGongGao shangJiaIsReadZhongXinGongGaoBll = new Bll.ShangJiaIsReadZhongXinGongGao();
                jsonResult = shangJiaIsReadZhongXinGongGaoBll.Add(shangJiaIsReadZhongXinGongGao);
            }
            catch (Exception ex)
            {
                Bll.ExceptionRepository.AddException(ex);
                Logger.WriteErrorLog("AddShangJiaIsReadZhongXinGongGaoException", ex);
                jsonResult.Success = false;
                jsonResult.ErrorMessage = Chinaer.Core.Helper.ExceptionMessageHelper.RollException(ex);
                jsonResult.LoginStatus = Chinaer.Core.BaseCore.LoginStatus.Exception;
            }
            return jsonResult;
        }

        public Chinaer.Model.Common.JsonResult UpdateShangJiaIsReadZhongXinGongGao(DTO.ShangJiaIsReadZhongXinGongGaoDTO shangJiaIsReadZhongXinGongGao)
        {
            WriteLog("UpdateShangJiaIsReadZhongXinGongGao", Chinaer.Core.Helper.SerializeHelper.Serialize(shangJiaIsReadZhongXinGongGao));
            Model.Common.JsonResult jsonResult = new Model.Common.JsonResult();
            try
            {
                IBll.IShangJiaIsReadZhongXinGongGao shangJiaIsReadZhongXinGongGaoBll = new Bll.ShangJiaIsReadZhongXinGongGao();
                jsonResult = shangJiaIsReadZhongXinGongGaoBll.Update(shangJiaIsReadZhongXinGongGao);
            }
            catch (Exception ex)
            {
                Bll.ExceptionRepository.AddException(ex);
                Logger.WriteErrorLog("UpdateShangJiaIsReadZhongXinGongGaoException", ex);
                jsonResult.Success = false;
                jsonResult.ErrorMessage = Chinaer.Core.Helper.ExceptionMessageHelper.RollException(ex);
                jsonResult.LoginStatus = Chinaer.Core.BaseCore.LoginStatus.Exception;
            }
            return jsonResult;
        }

        public Chinaer.Model.Common.JsonResult DeleteShangJiaIsReadZhongXinGongGao(DTO.ShangJiaIsReadZhongXinGongGaoDTO shangJiaIsReadZhongXinGongGao)
        {
            WriteLog("DeleteShangJiaIsReadZhongXinGongGao", Chinaer.Core.Helper.SerializeHelper.Serialize(shangJiaIsReadZhongXinGongGao));
            Model.Common.JsonResult jsonResult = new Model.Common.JsonResult();
            try
            {
                IBll.IShangJiaIsReadZhongXinGongGao shangJiaIsReadZhongXinGongGaoBll = new Bll.ShangJiaIsReadZhongXinGongGao();
                jsonResult = shangJiaIsReadZhongXinGongGaoBll.Delete(shangJiaIsReadZhongXinGongGao);
            }
            catch (Exception ex)
            {
                Bll.ExceptionRepository.AddException(ex);
                Logger.WriteErrorLog("DeleteShangJiaIsReadZhongXinGongGaoException", ex);
                jsonResult.Success = false;
                jsonResult.ErrorMessage = Chinaer.Core.Helper.ExceptionMessageHelper.RollException(ex);
                jsonResult.LoginStatus = Chinaer.Core.BaseCore.LoginStatus.Exception;
            }
            return jsonResult;
        }

        public Chinaer.Model.Common.JsonResult DeleteShangJiaIsReadZhongXinGongGaoByID(string ID, string apiToken)
        {
            WriteLog("DeleteShangJiaIsReadZhongXinGongGaoByID", string.Format("ID:{0} apiToken:{1}", ID, apiToken));
            Model.Common.JsonResult jsonResult = new Model.Common.JsonResult();
            try
            {
                IBll.IShangJiaIsReadZhongXinGongGao shangJiaIsRead = new Bll.ShangJiaIsReadZhongXinGongGao();
                jsonResult.Success = true;
            }
            catch (Exception ex)
            {
                Bll.ExceptionRepository.AddException(ex);
                Logger.WriteErrorLog("DeleteShangJiaIsReadZhongXinGongGaoByIDException", ex);
                jsonResult.Success = false;
                jsonResult.ErrorMessage = Chinaer.Core.Helper.ExceptionMessageHelper.RollException(ex);
                jsonResult.LoginStatus = Chinaer.Core.BaseCore.LoginStatus.Exception;
            }
            return jsonResult;
        }

        public Chinaer.Model.Common.JsonResult GetShangJiaIsReadZhongXinGongGaoStatus(string shangJiaID, string zhongXinGongGaoID, string apiToken)
        {
            WriteLog("GetShangJiaIsReadZhongXinGongGaoStatus", string.Format("shangJiaID:{0} zhongXinGongGaoID:{1} apitoken:{2}", shangJiaID, zhongXinGongGaoID, apiToken));
            Model.Common.JsonResult jsonResult = new Model.Common.JsonResult();
            try
            {
                IBll.IShangJiaIsReadZhongXinGongGao shangJiaIsRead = new Bll.ShangJiaIsReadZhongXinGongGao();
                jsonResult = shangJiaIsRead.GetShangJiaIsReadZhongXinGongGao(shangJiaID, zhongXinGongGaoID);

            }
            catch (Exception ex)
            {
                Bll.ExceptionRepository.AddException(ex);
                Logger.WriteErrorLog("GetShangJiaIsReadZhongXinGongGaoStatusException", ex);
                jsonResult.Success = false;
                jsonResult.ErrorMessage = Chinaer.Core.Helper.ExceptionMessageHelper.RollException(ex);
                jsonResult.LoginStatus = Chinaer.Core.BaseCore.LoginStatus.Exception;
            }
            return jsonResult;
        }

        public List<DTO.ZhongXinGongGaoDTO> GetAllZhongXinGongGao(string shangJiaID, string apiToken)
        {
            WriteLog("GetAllZhongXinGongGao", string.Format("shangJiaID:{0} apiToken:{1}", shangJiaID, apiToken));
            try
            {
                IBll.IZhongXinGongGao zhongxinGongGao = new Bll.ZhongXinGongGao();
                return zhongxinGongGao.GetAllZhongXinGongGao(shangJiaID);
            }
            catch (Exception ex)
            {
                Bll.ExceptionRepository.AddException(ex);
                Logger.WriteErrorLog("GetAllZhongXinGongGaoException", ex);
                return null;
            }
        }

        public DTO.DianPuYingYeStatusDTO GetDianPuYingYeStatus(string dianPuID, string apiToken)
        {
            WriteLog("GetDianPuYingYeStatus", string.Format("dianPuID:{0} apitoken:{1}", dianPuID, apiToken));
            DTO.DianPuYingYeStatusDTO dianPuYingYeStatusDTO = new DTO.DianPuYingYeStatusDTO();
            try
            {
                IBll.IDianPuYingYeStatus dianPuYingYeStatus = new Bll.DianPuYingYeStatus();
                dianPuYingYeStatusDTO = dianPuYingYeStatus.GetDianPuYingYeStatusByDianPuID(dianPuID);
            }
            catch (Exception ex)
            {
                Bll.ExceptionRepository.AddException(ex);
                Logger.WriteErrorLog("GetDianPuYingYeStatusException", ex);
                dianPuYingYeStatusDTO.LoginStatus = Chinaer.Core.BaseCore.LoginStatus.Exception;
            }
            return dianPuYingYeStatusDTO;
        }

        public Chinaer.Model.Common.JsonResult UpdateDianPuYingYeStatus(DTO.DianPuYingYeStatusDTO dianPuYingYeStatusDTO)
        {
            WriteLog("UpdateDianPuYingYeStatus", Chinaer.Core.Helper.SerializeHelper.Serialize(dianPuYingYeStatusDTO));
            Model.Common.JsonResult jsonResult = new Model.Common.JsonResult();
            try
            {
                IBll.IDianPuYingYeStatus dianPuYingYeStatus = new Bll.DianPuYingYeStatus();
                jsonResult = dianPuYingYeStatus.Update(dianPuYingYeStatusDTO);
            }
            catch (Exception ex)
            {
                Bll.ExceptionRepository.AddException(ex);
                Logger.WriteErrorLog("UpdateDianPuYingYeStatusException", ex);
                jsonResult.Success = false;
                jsonResult.ErrorMessage = Chinaer.Core.Helper.ExceptionMessageHelper.RollException(ex);
                jsonResult.LoginStatus = Chinaer.Core.BaseCore.LoginStatus.Exception;
            }
            return jsonResult;
        }

        public string DoWork(string value)
        {
            Chinaer.Model.Common.JsonResult jsonResult = new Model.Common.JsonResult();
            jsonResult.Success = true;
            return Chinaer.Core.Helper.Mobile.JsonHelper.GetJsonResult(jsonResult);
        }

        public Chinaer.Model.Common.JsonResult AddCountry(DTO.CountryDTO countryDTO)
        {
            WriteLog("AddCountry", Chinaer.Core.Helper.SerializeHelper.Serialize(countryDTO));
            Model.Common.JsonResult jsonResult = new Model.Common.JsonResult();
            try
            {
                IBll.ICountry country = new Bll.Country();
                jsonResult = country.Add(countryDTO);
            }
            catch (Exception ex)
            {
                Bll.ExceptionRepository.AddException(ex);
                Logger.WriteErrorLog("AddCountryException", ex);
                jsonResult.Success = false;
                jsonResult.ErrorMessage = Chinaer.Core.Helper.ExceptionMessageHelper.RollException(ex);
                jsonResult.LoginStatus = Chinaer.Core.BaseCore.LoginStatus.Exception;
            }
            return jsonResult;
        }

        public Chinaer.Model.Common.JsonResult DeleteCountry(DTO.CountryDTO countryDTO)
        {
            WriteLog("DeleteCountry", Chinaer.Core.Helper.SerializeHelper.Serialize(countryDTO));
            Model.Common.JsonResult jsonResult = new Model.Common.JsonResult();
            try
            {
                IBll.ICountry country = new Bll.Country();
                jsonResult = country.Delete(countryDTO);

            }
            catch (Exception ex)
            {
                Bll.ExceptionRepository.AddException(ex);
                Logger.WriteErrorLog("DeleteCountryException", ex);
                jsonResult.Success = false;
                jsonResult.ErrorMessage = Chinaer.Core.Helper.ExceptionMessageHelper.RollException(ex);
                jsonResult.LoginStatus = Chinaer.Core.BaseCore.LoginStatus.Exception;
            }
            return jsonResult;
        }

        public Chinaer.Model.Common.JsonResult DeleteCountryByID(string countryID, string apiToken)
        {
            WriteLog("DeleteCountryByID", string.Format("countryID:{0} apitoken:{1}", countryID, apiToken));
            Model.Common.JsonResult jsonResult = new Model.Common.JsonResult();
            try
            {
                IBll.ICountry country = new Bll.Country();
                jsonResult = country.Delete(countryID);

            }
            catch (Exception ex)
            {
                Bll.ExceptionRepository.AddException(ex);
                Logger.WriteErrorLog("DeleteCountryByIDException", ex);
                jsonResult.Success = false;
                jsonResult.ErrorMessage = Chinaer.Core.Helper.ExceptionMessageHelper.RollException(ex);
                jsonResult.LoginStatus = Chinaer.Core.BaseCore.LoginStatus.Exception;
            }
            return jsonResult;
        }

        public Chinaer.Model.Common.JsonResult UpdateCountry(DTO.CountryDTO countryDTO)
        {
            WriteLog("UpdateCountry", Chinaer.Core.Helper.SerializeHelper.Serialize(countryDTO));
            Model.Common.JsonResult jsonResult = new Model.Common.JsonResult();
            try
            {
                IBll.ICountry country = new Bll.Country();
                jsonResult = country.Update(countryDTO);
            }
            catch (Exception ex)
            {
                Bll.ExceptionRepository.AddException(ex);
                Logger.WriteErrorLog("UpdateCountryException", ex);
                jsonResult.Success = false;
                jsonResult.ErrorMessage = Chinaer.Core.Helper.ExceptionMessageHelper.RollException(ex);
                jsonResult.LoginStatus = Chinaer.Core.BaseCore.LoginStatus.Exception;
            }
            return jsonResult;
        }

        public List<DTO.CountryDTO> GetAllCountry(string apiToken)
        {
            WriteLog("GetAllCountry", string.Format("apiToken:{0}", apiToken));
            try
            {
                List<DTO.CountryDTO> listCountryDTO = new List<DTO.CountryDTO>();
                IBll.ICountry country = new Bll.Country();
                return country.GetAllCountry(apiToken);
            }
            catch (Exception ex)
            {
                Bll.ExceptionRepository.AddException(ex);
                Logger.WriteErrorLog("GetAllCountryException", ex);
                return null;
            }
        }

        public DTO.CountryDTO GetCountryByID(string countryID, string apiToken)
        {
            WriteLog("GetCountryByID", string.Format("countryID:{0} apiToken:{1}", countryID, apiToken));
            DTO.CountryDTO countryDTO = new DTO.CountryDTO();
            try
            {
                IBll.ICountry country = new Bll.Country();
                countryDTO = country.GetByID(countryID);
            }
            catch (Exception ex)
            {
                Bll.ExceptionRepository.AddException(ex);
                Logger.WriteErrorLog("GetCountryByIDException", ex);
                countryDTO.LoginStatus = Chinaer.Core.BaseCore.LoginStatus.Exception;
            }
            return countryDTO;
        }

        public Chinaer.Model.Common.JsonResult AddProvince(DTO.ProvinceDTO provinceDTO)
        {
            WriteLog("AddProvince", Chinaer.Core.Helper.SerializeHelper.Serialize(provinceDTO));
            Model.Common.JsonResult jsonResult = new Model.Common.JsonResult();
            try
            {
                IBll.IProvince province = new Bll.Province();
                jsonResult = province.Add(provinceDTO);

            }
            catch (Exception ex)
            {
                Bll.ExceptionRepository.AddException(ex);
                Logger.WriteErrorLog("AddProvinceException", ex);
                jsonResult.Success = false;
                jsonResult.ErrorMessage = Chinaer.Core.Helper.ExceptionMessageHelper.RollException(ex);
                jsonResult.LoginStatus = Chinaer.Core.BaseCore.LoginStatus.Exception;
            }
            return jsonResult;
        }

        public Chinaer.Model.Common.JsonResult UpdateProvince(DTO.ProvinceDTO provinceDTO)
        {
            WriteLog("UpdateProvince", Chinaer.Core.Helper.SerializeHelper.Serialize(provinceDTO));
            Model.Common.JsonResult jsonResult = new Model.Common.JsonResult();
            try
            {
                IBll.IProvince province = new Bll.Province();
                jsonResult = province.Update(provinceDTO);

            }
            catch (Exception ex)
            {
                Bll.ExceptionRepository.AddException(ex);
                Logger.WriteErrorLog("UpdateProvinceException", ex);
                jsonResult.Success = false;
                jsonResult.ErrorMessage = Chinaer.Core.Helper.ExceptionMessageHelper.RollException(ex);
                jsonResult.LoginStatus = Chinaer.Core.BaseCore.LoginStatus.Exception;
            }
            return jsonResult;
        }

        public Chinaer.Model.Common.JsonResult DeleteProvince(DTO.ProvinceDTO provinceDTO)
        {
            WriteLog("DeleteProvince", Chinaer.Core.Helper.SerializeHelper.Serialize(provinceDTO));
            Model.Common.JsonResult jsonResult = new Model.Common.JsonResult();
            try
            {
                IBll.IProvince province = new Bll.Province();
                jsonResult = province.Delete(provinceDTO);

            }
            catch (Exception ex)
            {
                Bll.ExceptionRepository.AddException(ex);
                Logger.WriteErrorLog("DeleteProvinceException", ex);
                jsonResult.Success = false;
                jsonResult.ErrorMessage = Chinaer.Core.Helper.ExceptionMessageHelper.RollException(ex);
                jsonResult.LoginStatus = Chinaer.Core.BaseCore.LoginStatus.Exception;
            }
            return jsonResult;
        }

        public Chinaer.Model.Common.JsonResult DeleteProvinceByID(string provinceID, string apiToken)
        {
            WriteLog("DeleteProvinceByID", string.Format("provinceID:{0} apitoken:{1}", provinceID, apiToken));
            Model.Common.JsonResult jsonResult = new Model.Common.JsonResult();
            try
            {
                IBll.IProvince province = new Bll.Province();
                jsonResult = province.Delete(provinceID);

            }
            catch (Exception ex)
            {
                Bll.ExceptionRepository.AddException(ex);
                Logger.WriteErrorLog("DeleteProvinceByIDException", ex);
                jsonResult.Success = false;
                jsonResult.ErrorMessage = Chinaer.Core.Helper.ExceptionMessageHelper.RollException(ex);
                jsonResult.LoginStatus = Chinaer.Core.BaseCore.LoginStatus.Exception;
            }
            return jsonResult;
        }

        public List<DTO.ProvinceDTO> GetProvinceByCountryID(string countryID, string apiToken)
        {
            WriteLog("GetProvinceByCountryID", string.Format("countryID:{0} apiToken:{1}", countryID, apiToken));
            try
            {
                IBll.IProvince province = new Bll.Province();
                List<DTO.ProvinceDTO> listProvinceDTO = province.GetByCountryID(countryID);
                return listProvinceDTO;
            }
            catch (Exception ex)
            {
                Bll.ExceptionRepository.AddException(ex);
                Logger.WriteErrorLog("GetProvinceByCountryIDException", ex);
                return null;
            }

        }

        public DTO.MenuCategoryDTO GetMenucategoryByName(string menucategoryName, string apiToken)
        {
            WriteLog("GetMenucategoryByName", string.Format("menucategoryName:{0} apiToken:{1}", menucategoryName, apiToken));
            DTO.MenuCategoryDTO menuCategoryDTO = new DTO.MenuCategoryDTO();
            try
            {
                IBll.IMenuCategory menucategory = new Bll.MenuCategory();
                menuCategoryDTO = menucategory.GetMenucategoryByName(menucategoryName);
            }
            catch (Exception ex)
            {
                Bll.ExceptionRepository.AddException(ex);
                Logger.WriteErrorLog("GetMenucategoryByNameException", ex);
                menuCategoryDTO.LoginStatus = Chinaer.Core.BaseCore.LoginStatus.Exception;
            }
            return menuCategoryDTO;
        }

        public List<DTO.DingDanStatusDTO> GetAllDingDanStatus(string apiToken)
        {
            WriteLog("GetAllDingDanStatus", string.Format("apitoken:{0}", apiToken));
            try
            {
                IBll.IDingDanStatus dingDanStatus = new Bll.DingDanStatus();
                return dingDanStatus.GetAllDingDanStatus();
            }
            catch (Exception ex)
            {
                Bll.ExceptionRepository.AddException(ex);
                Logger.WriteErrorLog("GetAllDingDanStatusException", ex);
                return null;
            }
        }

        public Chinaer.Model.Common.JsonResult AddDingDanStatus(DTO.DingDanStatusDTO dingDanStatusDTO)
        {
            WriteLog("AddDingDanStatus", Chinaer.Core.Helper.SerializeHelper.Serialize(dingDanStatusDTO));
            Model.Common.JsonResult jsonResult = new Model.Common.JsonResult();
            try
            {
                IBll.IDingDanStatus dingDanStatus = new Bll.DingDanStatus();
                jsonResult = dingDanStatus.Add(dingDanStatusDTO);
            }
            catch (Exception ex)
            {
                Bll.ExceptionRepository.AddException(ex);
                Logger.WriteErrorLog("AddDingDanStatusException", ex);
                jsonResult.Success = false;
                jsonResult.LoginStatus = Chinaer.Core.BaseCore.LoginStatus.Exception;
                jsonResult.ErrorMessage = Chinaer.Core.Helper.ExceptionMessageHelper.RollException(ex);
            }
            return jsonResult;
        }

        public Chinaer.Model.Common.JsonResult UpdateDingDanStatus(DTO.DingDanStatusDTO dingDanStatusDTO)
        {
            WriteLog("UpdateDingDanStatus", Chinaer.Core.Helper.SerializeHelper.Serialize(dingDanStatusDTO));
            Model.Common.JsonResult jsonResult = new Model.Common.JsonResult();
            try
            {
                IBll.IDingDanStatus dingDanStatus = new Bll.DingDanStatus();
                jsonResult = dingDanStatus.Update(dingDanStatusDTO);
            }
            catch (Exception ex)
            {
                Bll.ExceptionRepository.AddException(ex);
                Logger.WriteErrorLog("UpdateDingDanStatusException", ex);
                jsonResult.Success = false;
                jsonResult.LoginStatus = Chinaer.Core.BaseCore.LoginStatus.Exception;
                jsonResult.ErrorMessage = Chinaer.Core.Helper.ExceptionMessageHelper.RollException(ex);
            }
            return jsonResult;
        }

        public Chinaer.Model.Common.JsonResult DeleteDingDanStatus(DTO.DingDanStatusDTO dingDanStatusDTO)
        {
            WriteLog("DeleteDingDanStatus", Chinaer.Core.Helper.SerializeHelper.Serialize(dingDanStatusDTO));
            Model.Common.JsonResult jsonResult = new Model.Common.JsonResult();
            try
            {
                IBll.IDingDanStatus dingDanStatus = new Bll.DingDanStatus();
                jsonResult = dingDanStatus.Delete(dingDanStatusDTO);
            }
            catch (Exception ex)
            {
                Bll.ExceptionRepository.AddException(ex);
                Logger.WriteErrorLog("DeleteDingDanStatusException", ex);
                jsonResult.Success = false;
                jsonResult.LoginStatus = Chinaer.Core.BaseCore.LoginStatus.Exception;
                jsonResult.ErrorMessage = Chinaer.Core.Helper.ExceptionMessageHelper.RollException(ex);
            }
            return jsonResult;
        }

        public Chinaer.Model.Common.JsonResult DeleteDingDanStatusByID(string dingDanID, string apiToken)
        {
            WriteLog("DeleteDingDanStatusByID", string.Format("dingDanID:{0} apiToken:{1}", dingDanID, apiToken));
            Model.Common.JsonResult jsonResult = new Model.Common.JsonResult();
            try
            {
                IBll.IDingDanStatus dingDanStatus = new Bll.DingDanStatus();
                jsonResult = dingDanStatus.Delete(dingDanID);
            }
            catch (Exception ex)
            {
                Bll.ExceptionRepository.AddException(ex);
                Logger.WriteErrorLog("DeleteDingDanStatusByIDException", ex);
                jsonResult.Success = false;
                jsonResult.LoginStatus = Chinaer.Core.BaseCore.LoginStatus.Exception;
                jsonResult.ErrorMessage = Chinaer.Core.Helper.ExceptionMessageHelper.RollException(ex);
            }
            return jsonResult;
        }



        public Model.Common.JsonResult DeleteZhongXinGongGaoByID(string zhongXinGongGaoID, string apiToken)
        {
            WriteLog("DeleteZhongXinGongGaoByID", string.Format("zhongXinGongGaoID:{0} apiToken:{1}", zhongXinGongGaoID, apiToken));
            Model.Common.JsonResult jsonResult = new Model.Common.JsonResult();
            try
            {
                IBll.IZhongXinGongGao dingDanStatus = new Bll.ZhongXinGongGao();
                jsonResult = dingDanStatus.Delete(zhongXinGongGaoID);
            }
            catch (Exception ex)
            {
                Bll.ExceptionRepository.AddException(ex);
                Logger.WriteErrorLog("DeleteZhongXinGongGaoByIDException", ex);
                jsonResult.Success = false;
                jsonResult.LoginStatus = Chinaer.Core.BaseCore.LoginStatus.Exception;
                jsonResult.ErrorMessage = Chinaer.Core.Helper.ExceptionMessageHelper.RollException(ex);
            }
            return jsonResult;
        }

        public Model.Common.JsonResult AddZhongXinGongGao(DTO.ZhongXinGongGaoDTO zhongXinGongGaoDTO)
        {
            WriteLog("AddZhongXinGongGao", Chinaer.Core.Helper.SerializeHelper.Serialize(zhongXinGongGaoDTO));
            Model.Common.JsonResult jsonResult = new Model.Common.JsonResult();
            try
            {
                IBll.IZhongXinGongGao dingDanStatus = new Bll.ZhongXinGongGao();
                jsonResult = dingDanStatus.Add(zhongXinGongGaoDTO);
            }
            catch (Exception ex)
            {
                Bll.ExceptionRepository.AddException(ex);
                Logger.WriteErrorLog("AddZhongXinGongGaoException", ex);
                jsonResult.Success = false;
                jsonResult.LoginStatus = Chinaer.Core.BaseCore.LoginStatus.Exception;
                jsonResult.ErrorMessage = Chinaer.Core.Helper.ExceptionMessageHelper.RollException(ex);
            }
            return jsonResult;
        }

        public Model.Common.JsonResult UpdateZhongXinGongGao(DTO.ZhongXinGongGaoDTO zhongXinGongGaoDTO)
        {
            WriteLog("UpdateZhongXinGongGao", Chinaer.Core.Helper.SerializeHelper.Serialize(zhongXinGongGaoDTO));
            Model.Common.JsonResult jsonResult = new Model.Common.JsonResult();
            try
            {
                IBll.IZhongXinGongGao dingDanStatus = new Bll.ZhongXinGongGao();
                jsonResult = dingDanStatus.Update(zhongXinGongGaoDTO);
            }
            catch (Exception ex)
            {
                Bll.ExceptionRepository.AddException(ex);
                Logger.WriteErrorLog("UpdateZhongXinGongGaoException", ex);
                jsonResult.Success = false;
                jsonResult.LoginStatus = Chinaer.Core.BaseCore.LoginStatus.Exception;
                jsonResult.ErrorMessage = Chinaer.Core.Helper.ExceptionMessageHelper.RollException(ex);
            }
            return jsonResult;
        }

        public Model.Common.JsonResult DeleteZhongXinGongGao(DTO.ZhongXinGongGaoDTO zhongXinGongGaoDTO)
        {
            WriteLog("DeleteZhongXinGongGao", Chinaer.Core.Helper.SerializeHelper.Serialize(zhongXinGongGaoDTO));
            Model.Common.JsonResult jsonResult = new Model.Common.JsonResult();
            try
            {
                IBll.IZhongXinGongGao dingDanStatus = new Bll.ZhongXinGongGao();
                jsonResult = dingDanStatus.Delete(zhongXinGongGaoDTO);
            }
            catch (Exception ex)
            {
                Bll.ExceptionRepository.AddException(ex);
                Logger.WriteErrorLog("DeleteZhongXinGongGaoException", ex);
                jsonResult.Success = false;
                jsonResult.LoginStatus = Chinaer.Core.BaseCore.LoginStatus.Exception;
                jsonResult.ErrorMessage = Chinaer.Core.Helper.ExceptionMessageHelper.RollException(ex);
            }
            return jsonResult;
        }


        public List<DTO.AreaDTO> GetAreasByCityID(string cityID)
        {
            WriteLog("GetAreasByCityID", string.Format("cityID:{0}", cityID));
            List<DTO.AreaDTO> listArea = new List<DTO.AreaDTO>();
            try
            {
                IBll.IArea dingDanStatus = new Bll.Area();
                listArea = dingDanStatus.GetAreaByCityID(cityID);
            }
            catch (Exception ex)
            {
                Bll.ExceptionRepository.AddException(ex);
                Logger.WriteErrorLog("DeleteZhongXinGongGaoException", ex);
                return null;
            }
            return listArea;
        }


        public Model.Common.JsonResult AddArea(DTO.AreaDTO areaDTO)
        {
            WriteLog("SaveArea", Chinaer.Core.Helper.SerializeHelper.Serialize(areaDTO));
            Model.Common.JsonResult jsonResult = new Model.Common.JsonResult();
            try
            {
                IBll.IArea dingDanStatus = new Bll.Area();
                jsonResult = dingDanStatus.Add(areaDTO);
            }
            catch (Exception ex)
            {
                Bll.ExceptionRepository.AddException(ex);
                Logger.WriteErrorLog("SaveAreaException", ex);
                jsonResult.ErrorMessage = Chinaer.Core.Helper.ExceptionMessageHelper.RollException(ex);
                jsonResult.Success = false;
                jsonResult.LoginStatus = Chinaer.Core.BaseCore.LoginStatus.Exception;
            }
            return jsonResult;
        }

        public Model.Common.JsonResult UpdateArea(DTO.AreaDTO areaDTO)
        {
            WriteLog("UpdateArea", Chinaer.Core.Helper.SerializeHelper.Serialize(areaDTO));
            Model.Common.JsonResult jsonResult = new Model.Common.JsonResult();
            try
            {
                IBll.IArea dingDanStatus = new Bll.Area();
                jsonResult = dingDanStatus.Update(areaDTO);
            }
            catch (Exception ex)
            {
                Bll.ExceptionRepository.AddException(ex);
                Logger.WriteErrorLog("UpdateAreaException", ex);
                jsonResult.ErrorMessage = Chinaer.Core.Helper.ExceptionMessageHelper.RollException(ex);
                jsonResult.Success = false;
                jsonResult.LoginStatus = Chinaer.Core.BaseCore.LoginStatus.Exception;
            }
            return jsonResult;
        }

        public Model.Common.JsonResult DeleteArea(DTO.AreaDTO areaDTO)
        {
            WriteLog("DeleteArea", Chinaer.Core.Helper.SerializeHelper.Serialize(areaDTO));
            Model.Common.JsonResult jsonResult = new Model.Common.JsonResult();
            try
            {
                IBll.IArea dingDanStatus = new Bll.Area();
                jsonResult = dingDanStatus.Delete(areaDTO);
            }
            catch (Exception ex)
            {
                Bll.ExceptionRepository.AddException(ex);
                Logger.WriteErrorLog("DeleteAreaException", ex);
                jsonResult.ErrorMessage = Chinaer.Core.Helper.ExceptionMessageHelper.RollException(ex);
                jsonResult.Success = false;
                jsonResult.LoginStatus = Chinaer.Core.BaseCore.LoginStatus.Exception;
            }
            return jsonResult;
        }

        public Model.Common.JsonResult DeleteAreaByID(string areaID)
        {
            WriteLog("DeleteAreaByID", string.Format("AreaID:{0}", areaID));
            Model.Common.JsonResult jsonResult = new Model.Common.JsonResult();
            try
            {
                IBll.IArea dingDanStatus = new Bll.Area();
                jsonResult = dingDanStatus.Delete(areaID);
            }
            catch (Exception ex)
            {
                Bll.ExceptionRepository.AddException(ex);
                Logger.WriteErrorLog("DeleteAreaByIDException", ex);
                jsonResult.ErrorMessage = Chinaer.Core.Helper.ExceptionMessageHelper.RollException(ex);
                jsonResult.Success = false;
                jsonResult.LoginStatus = Chinaer.Core.BaseCore.LoginStatus.Exception;
            }
            return jsonResult;
        }


        public List<DTO.AdministratorDTO> GetAllAdministrators(string apiToken)
        {
            WriteLog("GetAllAdministrators", string.Format("apiToken:{0}", apiToken));
            List<DTO.AdministratorDTO> listAdministratorDTO = new List<DTO.AdministratorDTO>();
            try
            {
                IBll.IAdministrator administrator = new Bll.Administrator();
                listAdministratorDTO = administrator.GetAllAdministrators();
            }
            catch (Exception ex)
            {
                Bll.ExceptionRepository.AddException(ex);
                Log.Logger.WriteErrorLog("GetAllAdministrators", ex);
            }
            return listAdministratorDTO;
        }

        public Model.Common.JsonResult AddAdministrator(DTO.AdministratorDTO administratorDTO)
        {
            WriteLog("AddAdministrator", Chinaer.Core.Helper.SerializeHelper.Serialize(administratorDTO));
            Model.Common.JsonResult jsonResult = new Model.Common.JsonResult();
            try
            {
                IBll.IAdministrator administrator = new Bll.Administrator();
                jsonResult = administrator.Add(administratorDTO);
            }
            catch (Exception ex)
            {
                Bll.ExceptionRepository.AddException(ex);
                Log.Logger.WriteErrorLog("AddAdministratorError", ex);
            }
            return jsonResult;
        }

        public Model.Common.JsonResult DeleteAdministrator(DTO.AdministratorDTO administratorDTO)
        {
            WriteLog("DeleteAdministrator", Chinaer.Core.Helper.SerializeHelper.Serialize(administratorDTO));
            Model.Common.JsonResult jsonResult = new Model.Common.JsonResult();
            try
            {
                IBll.IAdministrator administrator = new Bll.Administrator();
                jsonResult = administrator.Delete(administratorDTO);
            }
            catch (Exception ex)
            {
                Bll.ExceptionRepository.AddException(ex);
                Log.Logger.WriteErrorLog("DeleteAdministratorError", ex);
            }
            return jsonResult;
        }

        public Model.Common.JsonResult UpdateAdministrator(DTO.AdministratorDTO administratorDTO)
        {
            WriteLog("UpdateAdministrator", Chinaer.Core.Helper.SerializeHelper.Serialize(administratorDTO));
            Model.Common.JsonResult jsonResult = new Model.Common.JsonResult();
            try
            {
                IBll.IAdministrator administrator = new Bll.Administrator();
                jsonResult = administrator.Update(administratorDTO);
            }
            catch (Exception ex)
            {
                Bll.ExceptionRepository.AddException(ex);
                Log.Logger.WriteErrorLog("UpdateAdministratorError", ex);
            }
            return jsonResult;
        }

        public Model.Common.JsonResult DeleteAdministratorByID(string administratorID)
        {
            WriteLog("UpdateAdministrator", string.Format("administratorID:{0}", administratorID));
            Model.Common.JsonResult jsonResult = new Model.Common.JsonResult();
            try
            {
                IBll.IAdministrator administrator = new Bll.Administrator();
                jsonResult = administrator.Delete(administratorID);
            }
            catch (Exception ex)
            {
                Bll.ExceptionRepository.AddException(ex);
                Log.Logger.WriteErrorLog("UpdateAdministratorError", ex);
            }
            return jsonResult;
        }


        public List<DTO.ShangJiaDTO> GetAllShangJias(string apiToken)
        {
            WriteLog("GetAllShangJias", string.Format("apiToken:{0}", apiToken));
            List<DTO.ShangJiaDTO> listShangJiaDTO = new List<DTO.ShangJiaDTO>();
            try
            {
                IBll.IShangJia administrator = new Bll.ShangJia();
                listShangJiaDTO = administrator.GetAllShangJias(apiToken);
            }
            catch (Exception ex)
            {
                Bll.ExceptionRepository.AddException(ex);
                Log.Logger.WriteErrorLog("GetAllShangJiasError", ex);
            }
            return listShangJiaDTO;
        }


        public Model.Common.JsonResult UpdateShangJia(DTO.ShangJiaDTO shangJiaDTO)
        {
            WriteLog("UpdateShangJia", Chinaer.Core.Helper.SerializeHelper.Serialize(shangJiaDTO));
            Model.Common.JsonResult jsonResult = new Model.Common.JsonResult();
            try
            {
                IBll.IShangJia administrator = new Bll.ShangJia();
                jsonResult = administrator.UpdateShangJia(shangJiaDTO);
            }
            catch (Exception ex)
            {
                Bll.ExceptionRepository.AddException(ex);
                Log.Logger.WriteErrorLog("UpdateShangJiaError", ex);
                jsonResult = ex.ExceptionJsonResult();
            }
            return jsonResult;
        }

        public Model.Common.JsonResult DeleteShangJia(DTO.ShangJiaDTO shangJiaDTO)
        {

            WriteLog("DeleteShangJia", Chinaer.Core.Helper.SerializeHelper.Serialize(shangJiaDTO));
            Model.Common.JsonResult jsonResult = new Model.Common.JsonResult();
            try
            {
                IBll.IShangJia administrator = new Bll.ShangJia();
                jsonResult = administrator.DeleteShangJia(shangJiaDTO);
            }
            catch (Exception ex)
            {
                Bll.ExceptionRepository.AddException(ex);
                Log.Logger.WriteErrorLog("DeleteShangJiaError", ex);
                jsonResult = ex.ExceptionJsonResult();
            }
            return jsonResult;
        }

        public Model.Common.JsonResult DeleteShangJiaByID(string shangJiaID, string apiToken)
        {
            WriteLog("DeleteShangJiaByID", string.Format("shangJiaID:{0},ApiToken:{1}", shangJiaID, apiToken));
            Model.Common.JsonResult jsonResult = new Model.Common.JsonResult();
            try
            {
                IBll.IShangJia administrator = new Bll.ShangJia();
                jsonResult = administrator.DeleteShangJiaByID(shangJiaID, apiToken);
            }
            catch (Exception ex)
            {
                Bll.ExceptionRepository.AddException(ex);
                Log.Logger.WriteErrorLog("DeleteShangJiaByIDError", ex);
                jsonResult = ex.ExceptionJsonResult();
            }
            return jsonResult;
        }



        public Model.Common.JsonResult UpdateCustomer(DTO.CustomerDTO customerDTO)
        {
            WriteLog("UpdateCustomer", Chinaer.Core.Helper.SerializeHelper.Serialize(customerDTO));
            Model.Common.JsonResult jsonResult = new Model.Common.JsonResult();
            try
            {
                IBll.ICustomer customer = new Bll.Customer();
                jsonResult = customer.Update(customerDTO);
            }
            catch (Exception ex)
            {
                Bll.ExceptionRepository.AddException(ex);
                Log.Logger.WriteErrorLog("UpdateCustomerError", ex);
                jsonResult = ex.ExceptionJsonResult();
            }
            return jsonResult;
        }

        public Model.Common.JsonResult DeleteCustomerByID(string id, string apiToken)
        {
            WriteLog("DeleteCustomerByID", string.Format("DeleteCustomerByID:{0},ApiToken:{1}", id, apiToken));
            Model.Common.JsonResult jsonResult = new Model.Common.JsonResult();
            try
            {
                IBll.ICustomer customer = new Bll.Customer();
                jsonResult = customer.Delete(id);
            }
            catch (Exception ex)
            {
                Bll.ExceptionRepository.AddException(ex);
                Log.Logger.WriteErrorLog("DeleteCustomerByIDError", ex);
                jsonResult = ex.ExceptionJsonResult();
            }
            return jsonResult;
        }

        public List<DTO.CustomerDTO> GetAllCustomers(string apiToken)
        {
            WriteLog("GetAllCustomers", string.Format("apiToken:{0}", apiToken));
            List<DTO.CustomerDTO> listShangJiaDTO = new List<DTO.CustomerDTO>();
            try
            {
                IBll.ICustomer customer = new Bll.Customer();
                listShangJiaDTO = customer.GetAllCustomers(apiToken);
            }
            catch (Exception ex)
            {
                Bll.ExceptionRepository.AddException(ex);
                Log.Logger.WriteErrorLog("GetAllCustomersError", ex);
            }
            return listShangJiaDTO;
        }


        public List<DTO.DianPuDTO> GetAllDianPus(string apiToken)
        {
            WriteLog("GetAllDianPus", string.Format("apiToken:{0}", apiToken));
            List<DTO.DianPuDTO> listDianPuDTO = new List<DTO.DianPuDTO>();
            try
            {
                IBll.IDianPu customer = new Bll.DianPu();
                listDianPuDTO = customer.GetAllDianPus();
            }
            catch (Exception ex)
            {
                Bll.ExceptionRepository.AddException(ex);
                Log.Logger.WriteErrorLog("GetAllDianPusError", ex);
            }
            return listDianPuDTO;
        }


        public List<DTO.EmployeeDTO> GetEmployeesByDianPuID(string dianPuID, string apiToken)
        {
            WriteLog("GetEmployeesByDianPuID", string.Format("dianPuID:{1} apiToken:{0}", apiToken, dianPuID));
            List<DTO.EmployeeDTO> listDianPuDTO = new List<DTO.EmployeeDTO>();
            try
            {
                IBll.IEmployee customer = new Bll.Employee();
                listDianPuDTO = customer.GetEmployeesByDianPuID(dianPuID);
            }
            catch (Exception ex)
            {
                Bll.ExceptionRepository.AddException(ex);
                Log.Logger.WriteErrorLog("GetEmployeesByDianPuIDError", ex);
            }
            return listDianPuDTO;
        }

        public Model.Common.JsonResult AddEmployee(DTO.EmployeeDTO employeeDTO)
        {
            WriteLog("SaveEmployee", Chinaer.Core.Helper.SerializeHelper.Serialize(employeeDTO));
            Model.Common.JsonResult jsonResult = new Model.Common.JsonResult();
            try
            {
                IBll.IEmployee employee = new Bll.Employee();
                jsonResult = employee.Add(employeeDTO);
            }
            catch (Exception ex)
            {
                WriteLog("SaveEmployeeError", Chinaer.Core.Helper.ExceptionMessageHelper.RollException(ex));
                jsonResult = ex.ExceptionJsonResult();
            }
            return jsonResult;
        }

        public Model.Common.JsonResult UpdateEmployee(DTO.EmployeeDTO employeeDTO)
        {
            WriteLog("UpdateEmployee", Chinaer.Core.Helper.SerializeHelper.Serialize(employeeDTO));
            Model.Common.JsonResult jsonResult = new Model.Common.JsonResult();
            try
            {
                IBll.IEmployee employee = new Bll.Employee();
                jsonResult = employee.Update(employeeDTO);
            }
            catch (Exception ex)
            {
                WriteLog("UpdateEmployeeError", Chinaer.Core.Helper.ExceptionMessageHelper.RollException(ex));
                jsonResult = ex.ExceptionJsonResult();
            }
            return jsonResult;
        }

        public Model.Common.JsonResult DeleteEmployee(DTO.EmployeeDTO employeeDTO)
        {
            WriteLog("DeleteEmployee", Chinaer.Core.Helper.SerializeHelper.Serialize(employeeDTO));
            Model.Common.JsonResult jsonResult = new Model.Common.JsonResult();
            try
            {
                IBll.IEmployee employee = new Bll.Employee();
                jsonResult = employee.Delete(employeeDTO);
            }
            catch (Exception ex)
            {
                WriteLog("DeleteEmployeeError", Chinaer.Core.Helper.ExceptionMessageHelper.RollException(ex));
                jsonResult = ex.ExceptionJsonResult();
            }
            return jsonResult;
        }

        public Model.Common.JsonResult DeleteEmployeeByID(string employeeID, string apiToken)
        {
            WriteLog("DeleteEmployeeByID",string.Format("employeeID:{0} apiToken:{1}",employeeID,apiToken));
            Model.Common.JsonResult jsonResult = new Model.Common.JsonResult();
            try
            {
                IBll.IEmployee employee = new Bll.Employee();
                jsonResult = employee.Delete(employeeID);
            }
            catch (Exception ex)
            {
                WriteLog("DeleteEmployeeByIDError", Chinaer.Core.Helper.ExceptionMessageHelper.RollException(ex));
                jsonResult = ex.ExceptionJsonResult();
            }
            return jsonResult;
        }
    }
}
